/**
 * 
 */
package com.gkwave.action.service;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.gkwave.module.bean.MessageBean;
import com.gkwave.module.dao.EmailDAO;
import com.gkwave.module.dao.TradeProductDAO;
import com.gkwave.util.CloseTradingProduct;
/**
 * @author Dhanasekar R
 *
 */
public class TradeProductDisableService extends BaseService {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1234482252120412266L;

	/**
	 * 
	 */
	public TradeProductDisableService() {
		// TODO Auto-generated constructor stub
	}

	/* (non-Javadoc)
	 * @see com.gkwave.action.service.BaseService#procesRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	public void procesRequest(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String idTradeProduct = request.getParameter("idTradeProduct");
		out = response.getWriter();
		EmailDAO emailDao = null;
		if(idTradeProduct!=null){
			Integer id_trade_product = Integer.parseInt(idTradeProduct);
			TradeProductDAO dao = new TradeProductDAO();
			boolean returnvalue = dao.disableTradeProductById(id_trade_product);
			if(returnvalue){
				new CloseTradingProduct().sendMail(id_trade_product);
				MessageBean bean = new MessageBean("Success" , "ProductID["+idTradeProduct+"] dissabled successfully!!!");
				xmlResponse = bean.marsel(bean);
			} else{
				MessageBean bean = new MessageBean("Error" , "ProductID["+idTradeProduct+"] No data affected!!!");
				xmlResponse = bean.marsel(bean);
			}
		} else{
			xmlResponse = "Error: input parameter is empty!!! -[ idTradeProduct, " +idTradeProduct+" ]";
		}
		System.out.println(xmlResponse);
		out.println(xmlResponse);
	}

	private EmailDAO EmailDAO() {
		// TODO Auto-generated method stub
		return null;
	}

}
